﻿<%@ Page Language="C#" AutoEventWireup="true" validateRequest="false" CodeBehind="persondoc_mydoc_searchlist.aspx.cs" Inherits="Ccit.OA.PersonDoc.persondoc_mydoc_searchlist" %>

<%@ Register assembly="DevExpress.Web.ASPxGridView.v8.1" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v8.1" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>文件搜索页面</title>

     <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
     <script language="javascript" type="text/javascript">
            <!--
            /* 复选框选择 */
            function OnGridSelectionChanged(){
                dgMain.GetSelectedFieldValues("ID",OnGridSelectionComplete);
                dgMain.GetSelectedFieldValues("FileType",OnGridSelectionCompleteFold);    
                dgMain.GetSelectedFieldValues("Title",OnGridSelectionCompleteFoldName);    
            }
            
            function OnGridSelectionComplete(values){
                document.getElementById("hidIds").value = values;
               parent.frames.ztButton();
            }
            
            function OnGridSelectionCompleteFold(values){
                document.getElementById("hidFileType").value = values;
            }
            
            function OnGridSelectionCompleteFoldName(values){
                document.getElementById("hidFiesName").value = values;
            }
             //-->
        </script>
    <script type="text/javascript">
    
        function doDelete(ID,sType)
        {
            document.getElementById("hidIds").value = ID;
            document.getElementById("hidFileType").value = sType;
            if(confirm("确定删除文件(一旦删除文件,将无法在重新恢复文件)?"))
            {

                var jsonStr = jsonObj();
                PageMethods.DeleteFile(jsonStr,"Del",ClientCallBack) ;
            }
            else{
                document.getElementById("hidIds").value = "";
                document.getElementById("hidFileType").value = "";
            }
        }
        
        function doMenu()
        {
            parent.frames.doMenuBlock();
            parent.frames.doLoad();
        }
        
        //Frame删除
        function doBatDelete()
        {
            var vId = jQuery.trim($get("hidIds").value);
            if(vId == "")
            {
                alert("请先选择要删除的文件!");
                return false;
            }
            else
            {
                if(confirm("确定删除文件(一旦删除文件,将无法在重新恢复文件)?"))
                {
                    var jsonStr = jsonObj();
                    PageMethods.DeleteFile(jsonStr,"DelAll",ClientCallBack) ;
                }
            }
        }
        //粘贴
        function doShearFile()
        {
            var sWork = parent.frames.document.getElementById("hidWork").value; 
            if(parent.frames.document.getElementById("hidId").value  != "")
            {
                document.getElementById("hidIds").value = parent.frames.document.getElementById("hidId").value;
                document.getElementById("hidFileType").value = parent.frames.document.getElementById("hidType").value;
                document.getElementById("hidFiesName").value = parent.frames.document.getElementById("hidFiesName").value;
                 var jsonStr = jsonObj();
                 PageMethods.ShearFile(jsonStr,"ShearFile",sWork,ClientCallBack) ;
            }
            else
            {
                alert("请先选择要粘贴的文件!");
            }
        }
        
        //返回当前所属的文件夹ID号
        function getFolder()
        {
            return document.getElementById("hidFoldID").value;
        }
        
        //返回已经选中的文件ID（文件夹ID、文件ID）
        function getFileId()
        {
            return document.getElementById("hidIds").value ;
        }
        
        //返回已经选中的文件类别（文件夹、文件）
        function getFileType()
        {
            return document.getElementById("hidFileType").value;
        }
        //返回文件共享标志 （只读或完全共享）
        function getShare()
        {
            return document.getElementById('hidShareType').value;
        }
        
        function GetSpace()
        {
            return document.getElementById("hidsySpace").value;
        }
        
        //返回文档所属类别
        function getFoldType()
        {
            return document.getElementById("hidfolderType").value;
        }
        
        function jsonObj() //返回序列化后的字符串
        {
            var MsFiles ={};
            MsFiles.Id = $get("hidIds").value;
            MsFiles.userId = $get("hidUserId").value;
            MsFiles.folderId = $get("hidFoldID").value;
            MsFiles.fileName = "";
            MsFiles.fileType = $get("hidFileType").value;
            MsFiles.filelength = "";
            MsFiles.remark = "";
            MsFiles.updatetime = "";
            
            MsFiles.agencId = "";
            MsFiles.deptId = "";
            MsFiles.jobId = "";
            MsFiles.levelId = "";
            MsFiles.cjuserId = "";
            MsFiles.cjdatetime = "";
            
            var jsonStr = JSON.stringify(MsFiles,function(key,value){return value;});  
            return jsonStr;
        }
        
          function ClientCallBack(vResult) {
            eval("var resultObj=" + vResult);
            var operType = resultObj.operType;
            var resultSign = resultObj.resultSign;
            switch (operType) {
                case "DelAll": 
                    if (resultSign == "0") {
                        alert("删除失败!");
                    }
                    else {
                        parent.frames[0].document.getElementById("_hidClassType").value = document.getElementById("hidFileType").value; 
                        parent.frames[0].document.getElementById("_hidDelAddressId").value = resultObj.resultDelId; 
                        parent.frames[0].document.all.btnDelTrigger.click();   
                        var sParam = "folderID=" + document.getElementById("hidFoldID").value+"&UserIdShare=" + document.getElementById("hidUserId").value;
		                var encodeParam = base64encode(sParam);
                        parent.frames[1].location.href = "./persondoc_mydoc_list.aspx?"+encodeParam;
                    }
                    break;
                    case "Del": 
                    if (resultSign == "0") {
                        alert("删除失败!");
                    }
                    else { 
                      var sParam = "folderID=" + document.getElementById("hidFoldID").value+"&UserIdShare=" + document.getElementById("hidUserId").value;
		                var encodeParam = base64encode(sParam);
                        parent.frames[1].location.href = "./persondoc_mydoc_list.aspx?"+encodeParam;
                    }
                    break;
                    case "ShearFile":
                    if(resultSign == "0") {
                        if(resultObj.resulType == "Code") {
                            alert('复制失败!');
                        }
                        else{
                            alert("剪切失败!");
                        }
                    }
                    else
                    {
                    
                        //实例化MsFolder消息对象
                        var MsFolder = {};
                        MsFolder.FId= $get("hidIds").value;             
                        MsFolder.FName = $get("hidFiesName").value;         //文件名
                        alert($get("hidFiesName").value);
                        MsFolder.Superiorid = $get("hidFoldID").value;   //上级文件夹ID
                        MsFolder.FType = $get("hidFileType").value;   //上文件类型                        
                       
                        var jsonExpr=JSON.stringify(MsFolder,function(key,value){return value;});
                    
                        parent.frames[0].document.getElementById("_hidNewColumnId").value=jsonExpr;
                        parent.frames[0].document.getElementById("_hidAddNewSign").value = resultObj.resulType;  //操作标志记录标志 Code复制/Shear剪切
                        parent.frames[0].document.getElementById("_hidUpAddrId").value =  document.getElementById("hidFoldID").value;
                        parent.frames[0].document.all.btnTrigger.click(); 
                         
                         /*清楚父窗体对象值*/
                        parent.frames.document.getElementById("hidId").value = "";
                        parent.frames.document.getElementById("hidType").value = "";
                        parent.frames.document.getElementById("hidFiesName").value = "";
                        var sParam = "folderID=" + document.getElementById("hidFoldID").value+"&UserIdShare=" + document.getElementById("hidUserId").value;
		                var encodeParam = base64encode(sParam);
                        parent.frames[1].location.href = "./persondoc_mydoc_list.aspx?"+encodeParam;
                    }
                default:
                    break;
            }

            resultObj = null;
        }
        
        function OpenUpLoadPage(id) {
            var strURL = "persondoc_mydoc_download.aspx?"+id;
            OpenWindow(strURL,"",300,200);
            
        }
        
        function doEditFolder(folderID)
        {
            window.location.href = "persondoc_folder_edit.aspx?" + folderID;
            return false;
        }
        
        function doLocationFolder(folderID)
        {
            window.location.href = "persondoc_mydoc_searchlist.aspx?" + folderID;
        }
        
    </script>
</head>
<body onload="doMenu();">
        <ccit:ActionForm  id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true"/>
        <input type="hidden" id="hidIds" runat="server" />
        <input type="hidden" id="hidvar" runat="server" />
        <input type="hidden" id="hidFoldID" runat="server" />
        <input type="hidden" id="hidFileType" runat="server" />
        <input type="hidden" id="hidShareType" runat="server" />
        <input type="hidden" id="hidfolderType" runat="server" />
        <input type="hidden" id="hidsySpace" runat="server" />
        <input type="hidden" id="hidUserId" runat="server" />
        <input type="hidden" id="hidFiesName" runat="server" />
     <table  cellpadding="0" cellspacing="0" width="98%" align="center">
            <tr>
                <td>
                        <dxwgv:ASPxGridView ID="dgMain" runat="server"
                                AutoGenerateColumns="False" Width="100%" KeyFieldName="ID" 
                                            Settings-ShowGroupPanel="true" onhtmlrowcreated="dgMain_HtmlRowCreated" >
                                             <SettingsText GroupPanel="分组栏" />   
                                            <SettingsPager AlwaysShowPager="True" PageSize="15">
                                                <FirstPageButton Visible="True">
                                                </FirstPageButton>
                                                <LastPageButton Visible="True">
                                                </LastPageButton>
                                            </SettingsPager>
                                             <Styles>
                                                <Row CssClass=""></Row>
                                                <AlternatingRow  CssClass="" Enabled="true"/>
                                                <SelectedRow  CssClass=""></SelectedRow>                
                                            </Styles>  
                                            <Columns>
                                                 <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="5%">
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                    <HeaderTemplate>
                                                        <input type="checkbox" id="chbCheck" runat="server" onclick="dgMain.SelectAllRowsOnPage(this.checked);"
                                                            style="vertical-align: middle;" title="Select/Unselect all rows on the page"></input>
                                                    </HeaderTemplate>
                                                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
                                                        <Paddings PaddingTop="2px" PaddingBottom="2px"></Paddings>
                                                    </HeaderStyle>
                                                </dxwgv:GridViewCommandColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="" VisibleIndex="1" width="5%" >
                                                 <HeaderStyle HorizontalAlign="Center" />
                                                 <CellStyle HorizontalAlign="left" Wrap="False"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="名称" VisibleIndex="2" width="35%" FieldName="Title">
                                                 <HeaderStyle HorizontalAlign="Center" />
                                                 <CellStyle HorizontalAlign="left"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="路径" VisibleIndex="3" width="15%" FieldName="Url">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="left"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="大小" VisibleIndex="4" width="10%" FieldName="Length">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Right"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                 <dxwgv:GridViewDataTextColumn Caption="类型" VisibleIndex="5" width="10%" FieldName="FileType">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>                                                 
                                                 <dxwgv:GridViewDataTextColumn Caption="更新日期" VisibleIndex="6" width="15%" FieldName="Updatetime">
                                                  <HeaderStyle HorizontalAlign="Center" />
                                                  <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>
                                                <dxwgv:GridViewDataTextColumn Caption="记录ID" FieldName="ID" Visible="false" VisibleIndex="7"  ShowInCustomizationForm="false" >
                                                 <HeaderStyle HorizontalAlign="center" />
                                                 <CellStyle HorizontalAlign="Right"></CellStyle>
                                                </dxwgv:GridViewDataTextColumn>  
                                                  <dxwgv:GridViewDataColumn Caption="操作" VisibleIndex="8" Width="10%" Visible="false">
                                                <HeaderStyle HorizontalAlign="center" />
                                                <CellStyle HorizontalAlign="center"></CellStyle>
                                                <DataItemTemplate>
                                                  <nobr>
                                                    <asp:LinkButton ID="lnbEdit" runat="server">修改</asp:LinkButton>
                                                     <asp:LinkButton ID="lnbDel" runat="server">删除</asp:LinkButton>                            
                                                  </nobr>
                                                </DataItemTemplate>
                                            </dxwgv:GridViewDataColumn>      
                                               </Columns>
            <%-- 设置页脚中分页 --%>
            <SettingsPager PageSize=13 Mode="ShowPager" AlwaysShowPager=true
                 FirstPageButton-Visible=true LastPageButton-Visible=true  
                 FirstPageButton-Image-AlternateText="" LastPageButton-Image-AlternateText="尾页"
                 NumericButtonCount=5  SEOFriendly="Disabled"
                 PrevPageButton-Visible="true" NextPageButton-Visible="true"
                 ShowSeparators=true Position="Bottom">
                    <FirstPageButton Visible="True"></FirstPageButton>
                    <LastPageButton Visible="True">
                    <Image AlternateText="尾页"></Image>
                    </LastPageButton>
            </SettingsPager>
                 
            <%-- 复选框选择脚本事件--%>
            <ClientSideEvents SelectionChanged="function(s,e){OnGridSelectionChanged();}"                 
             />
            
            <%-- 设置行样式--%>
            <Styles>
                <Row CssClass=""></Row>
                <AlternatingRow  CssClass="" Enabled="true"/>
                <SelectedRow  CssClass=""></SelectedRow>                
            </Styles>
            <%--  显示过滤行--%>
            <Settings ShowFilterRow="false" ShowPreview="True"/>
            
            <%-- 可调整列宽--%>
            <SettingsBehavior ColumnResizeMode="Control" />
            
            <%-- 自定义表头--%>
            <SettingsCustomizationWindow Enabled="true" />
        </dxwgv:ASPxGridView>
				</td>
			</tr>
		</table>
		
				
    </ccit:ActionForm>
</body>
</html>
